home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_091 / adlcomp / adlmsg.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  124 lines

  1.     /***************************************************************\
  2.     *                                *
  3.     *    adlmsg.c - routines to print error messages during    *
  4.     *    compilation.                        *
  5.     *    Copyright 1987 by Ross Cunniff.                *
  6.     *                                *
  7.     \***************************************************************/
  8.  
  9. #include <stdio.h>
  10.  
  11. #include "adltypes.h"
  12. #include "adlprog.h"
  13. #include "adlcomp.h"
  14.  
  15.  
  16. /* Predefined error messages */
  17. char
  18.     *BRACKET_EXPECTED    = "']' expected.\n",
  19.     *BAD_ARRAY        = "Array size must be greater than 0.\n",
  20.     *LEFT_EXPECTED    = "'(' expected.\n",
  21.     *RIGHT_EXPECTED    = "')' expected.\n",
  22.     *SEMI_EXPECTED    = "';' expected.\n",
  23.     *COMMA_EXPECTED    = "',' expected.\n",
  24.     *NOUN_WANTED    = "Noun expected.\n",
  25.     *CONST_EXPECTED    = "Constant expected.\n",
  26.     *VAR_EXPECTED    = "Global expected.\n",
  27.     *EQUAL_EXPECTED    = "'=' expected.\n",
  28.     *PREP_EXPECTED    = "Preposition expected.\n",
  29.     *ATTEMPT    = "Attempt to use a modified noun without a modifier.\n",
  30.     *ILLEGAL_SYMBOL    = "Illegal symbol.\n";
  31.  
  32. int16
  33.     wignore = 0,    /* Ignore warning messages?            */
  34.     maxerr  = -1;    /* Maximum number of errors before crash    */
  35.  
  36.  
  37.     /***************************************************************\
  38.     *                                *
  39.     *    eatuntil( c ) - eat tokens until a token with type c    *
  40.     *    is found, and EOF is found, or a semicolon is found,    *
  41.     *    whichever comes first.                    *
  42.     *                                *
  43.     \***************************************************************/
  44.  
  45. eatuntil( c )
  46. int16
  47.     c;
  48. {
  49.     while( (t_type != c) && (t_type != EOF) ) {
  50.     if( (t_type == '(') && (c == ')') ) {
  51.         lexer();
  52.         eatuntil( ')' );
  53.     }
  54.     else if( t_type == ';' )
  55.         return;    /* Don't eat past a ';' */
  56.     lexer();
  57.    }
  58. }
  59.  
  60.  
  61.  
  62.     /***************************************************************\
  63.     *                                *
  64.     *    error( msg ) - Print ERROR: msg, increment the error    *
  65.     *    counter, and exit if too many errors have occurred.    *
  66.     *                                *
  67.     \***************************************************************/
  68.  
  69. error( s )
  70. char
  71.     *s;
  72. {
  73.     fprintf( stderr, "ERROR: %s", s );
  74.     if( t_type != EOF ) {
  75.     fprintf( stderr, "File \"%s\", line %d, token \"%s\"\n",
  76.              inname, numline, token );
  77.     fflush( stderr );
  78.     }
  79.     numerr++;
  80.     if( (maxerr >= 0) && (numerr > maxerr) )
  81.     fatal( "Maximum number of errors exceeded.\n" );
  82. }
  83.  
  84.  
  85.     /***************************************************************\
  86.     *                                *
  87.     *    warning( msg ) - If warning messages are enabled, print    *
  88.     *    the string WARNING: msg and increment the warning count.*
  89.     *                                *
  90.     \***************************************************************/
  91.  
  92. warning( s )
  93. char
  94.     *s;
  95. {
  96.     if( !wignore ) {
  97.     fprintf( stderr, "WARNING: %s", s );
  98.     if( t_type != EOF )
  99.         fprintf( stderr, "File \"%s\", line %d, token \"%s\"\n",
  100.                inname, numline, token );
  101.     fflush( stderr );
  102.     }
  103.     numwarn++;
  104. }
  105.  
  106.  
  107.     /***************************************************************\
  108.     *                                *
  109.     *    fatal( s ) - print the message FATAL ERROR: s and    *
  110.     *    exit the program.                    *
  111.     *                                *
  112.     \***************************************************************/
  113.  
  114. fatal( s )
  115. char
  116.     *s;
  117. {
  118.     fprintf( stderr, "FATAL ERROR: %s", s );
  119.     fputs( "ADL aborting.\n", stderr );
  120.     breaker();
  121. }
  122.  
  123. /*** EOF adlmsg.c ***/
  124.